
if exists(select name from sysobjects where name = 'sp_LienHeCreateEdit')
	drop proc sp_LienHeCreateEdit
go
/*
	Created by: Phuoc NH
	Created on: 13/05/2013 (dd/mm/yyyy)
	Description: 
	--

	File:$sql-scripts/Proc.sp_LienHeCreateEdit.sql
*/


-- =============================================
-- Author		: HP
-- Create date	: 2014-03-29
-- =============================================

CREATE PROCEDURE sp_LienHeCreateEdit
			
	@Id       		INT,
	@HoTen    		NVARCHAR(64),
	@DienThoai		VARCHAR(15),
	@Email    		VARCHAR(128),
	@NoiDung  		NVARCHAR(max)
	
AS
BEGIN
    IF(@Id=0)
        BEGIN
        	INSERT INTO LienHe
        	(
			[HoTen],
			[DienThoai],
			[Email],
			[NoiDung]
			
        	) 
        	VALUES 
        	(
			@HoTen,
			@DienThoai,
			@Email,
			@NoiDung
        	)
        END
     ELSE
        BEGIN
            UPDATE LienHe     
            SET
			[HoTen]     = @HoTen,
			[DienThoai] = @DienThoai,
			[Email]     = @Email,
			[NoiDung]   = @NoiDung			
		WHERE
				[Id]       = @Id;
			END
END
GO


